Shared Scripting

Shared scripting gives the ability to write R, Python, and SAS scripts. and share them with other Data Modeling users in the platform, without them needing to know the details of how the script was written or what it contains.

To see how to use a shared script in Model, via the Select Script function, see Scripting Engines.

Building a Shared Script

First, the script author picks the scripting language and then writes the relevant script into the console. Or if the script was developed elsewhere, the raw script text can be dragged into the browser or pasted in.

Next, the author "wires" up the script to further facilitate the sharing process. The wire up simplifies the deployment phase of the script and also acts as a hard guide for the user on how to plumb the incoming data to the script and how to take the script's results and plumb them back into the data flow and model.

  • Input - Given a selected \ joined \ manipulated table in Pyramid, each column required for the scripting should be added and mapped to a unique name in the scripting language and according to the language rules.
  • Output - The output of the script should be a column with a row number equal to the input table. The column type (Float, String, and Integer) is also required.
  • Table Output - The scripting can also output a new table.

Adding libraries

Some of the open source scripting languages, especially R and Python, can load different packages to solve existing ML problems. The package field allows authors to designate which packages the script will require - which Pyramid then has the ability to download and load (if needed).

Shared Scripting example using R

Get Logistic regression

This Example is based on the customer profile table in the spreadsheet demo. This example predicts a customer gender based on income and children.

Add 3 columns as inputs:

Gender, Income, children

Add the script:

customerProfile=data.frame(Gender,Income,Children)

lm=glm(customerProfile$Gender~customerProfile$Income+customerProfile$Children,family = binomial,data = customerProfile)

prediction=predict(lm, type = 'response')

resultProbability=as.data.frame(prediction)

resultProbability[,2]="female"

resultProbability[resultProbability[,1]<0.5,2]="male"

LRR =resultProbability[,2]

Add the output column:

Data Frame: DataFrame1

Column: LRR

Type: Text

Results

When deployed, a new column named LRR with male-female values will be added to the model.